package com.bsh.controller.account;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.bsh.api.ApiUtils;
import com.bsh.dto.AccountNoticeQryDto;
import com.bsh.dto.NoticeRefundQryDto;
import com.bsh.dto.UserEditDto;
import com.bsh.service.AccountNoticeService;
import com.bsh.service.AccountService;
import com.bsh.service.PaymentService;
import com.bsh.shiro.UserContext;
import com.bsh.utils.IpUtil;
import com.bsh.utils.PageJosnMessage;
import com.bsh.utils.PageTools;
import com.bsh.utils.Pager;
import com.bsh.utils.excel.ColumonCfg;
import com.bsh.utils.excel.ExcelExportor;
import com.mysql.jdbc.StringUtils;

/**
 * 账户变动日志
 * 
 * @author gsh
 *
 */
@Controller
public class AccountNoticeController {
	private static Logger log = LoggerFactory.getLogger(AccountNoticeController.class);

	@Autowired
	HttpServletRequest request;
	@Autowired
	HttpServletResponse response;
	@Autowired
	AccountNoticeService noticeService;
	@Autowired
	AccountService accService;
	@Autowired
	PaymentService paymentService;

	/**
	 * 设置查询默认时间范围
	 */
	private void setDefaultDateTimeRange(AccountNoticeQryDto dto){
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        if(ApiUtils.objIsEmpty(dto.getCreateTime())&&ApiUtils.objIsEmpty(dto.getCreateTime1())){
        	  Calendar cal=Calendar.getInstance();
    		  cal.setTime(new Date());	
    		  cal.add(Calendar.DAY_OF_MONTH,-3);
    		  dto.setCreateTime(sdf.format(cal.getTime()));
    		  dto.setCreateTime1(sdf.format(new Date()));
        }        
	}
	
	
	/**
	 * 后台管理员充值记录列表
	 */
	@RequestMapping(value = "/account/notice/admin_recharge")
	public ModelAndView rechargeByAdminList(@ModelAttribute AccountNoticeQryDto dto) {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/pages/account/rechargeByAdminNoticeList");

		String pageStr = request.getParameter("pageIndex");
		Integer pageIndex = Integer.parseInt(StringUtils.isNullOrEmpty(pageStr) ? "1" : pageStr);

		String sizeStr = request.getParameter("pageSize");
		Integer pageSize = Integer.parseInt(StringUtils.isNullOrEmpty(sizeStr) ? "10" : sizeStr);

		setDefaultDateTimeRange(dto);
		
		Pager pager = new Pager(pageIndex, pageSize);
		List<Map<String, Object>> list = noticeService.getRechargeByAdminPage(pager, dto);
		mv.addObject("list", list);
		mv.addObject("pager", pager);
		mv.addObject("dto", dto==null?new UserEditDto():dto);
		
		return mv;
	}
	
	/**
	 * 后台管理员充值记录列表--导出
	 * @return 
	 */
	@RequestMapping(value = "/account/notice/admin_recharge/export")
	public ModelAndView rechargeByAdminListExport(@ModelAttribute AccountNoticeQryDto dto) {
		ModelAndView mv = new ModelAndView();	
		List<Map<String, Object>> list = noticeService.getRechargeByAdminPageExport(dto);
		
		List<ColumonCfg> cfg=new ArrayList<>();
		cfg.add(new ColumonCfg("title","项目名称",250));
		cfg.add(new ColumonCfg("money","现金",100));
		cfg.add(new ColumonCfg("cloud_money","商币",100));
		cfg.add(new ColumonCfg("user_name","会员名",150));
		cfg.add(new ColumonCfg("sn","付款单号",250));
		cfg.add(new ColumonCfg("outer_sn","外部单号",100));
		cfg.add(new ColumonCfg("memo","备注",100));
		cfg.add(new ColumonCfg("payment_name","支付方式",100));
		cfg.add(new ColumonCfg("create_time","支付时间",160));
		cfg.add(new ColumonCfg("ispay","是否支付",100));			

		ExcelExportor.exportExcelByCfg("后台管理员充值记录.xls", cfg, list);
		
		return null;
	}
	
	
	
	
	
	/**
	 * 充值记录列表
	 */
	@RequestMapping(value = "/account/notice/recharge")
	public ModelAndView rechargeList(@ModelAttribute AccountNoticeQryDto dto) {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/pages/account/rechargeNoticeList");

		String pageStr = request.getParameter("pageIndex");
		Integer pageIndex = Integer.parseInt(StringUtils.isNullOrEmpty(pageStr) ? "1" : pageStr);

		String sizeStr = request.getParameter("pageSize");
		Integer pageSize = Integer.parseInt(StringUtils.isNullOrEmpty(sizeStr) ? "10" : sizeStr);

		List<Map<String, Object>> pmMapList = paymentService.getPaymentList("");
		
		setDefaultDateTimeRange(dto);
		
		Pager pager = new Pager(pageIndex, pageSize);
		List<Map<String, Object>> list = noticeService.getRechargePage(pager, dto);
		mv.addObject("list", list);
		mv.addObject("pager", pager);
		mv.addObject("paymentList", pmMapList);
		mv.addObject("dto", dto==null?new UserEditDto():dto);
		return mv;
	}

	/**
	 * 充值记录列表导出
	 */
	@RequestMapping(value = "/account/notice/recharge/export")
	public ModelAndView rechargeListExport(@ModelAttribute AccountNoticeQryDto dto) {
		ModelAndView mv = new ModelAndView();	
		List<Map<String, Object>> list = noticeService.getRechargePageExport(dto);
		
		List<ColumonCfg> cfg=new ArrayList<>();
		cfg.add(new ColumonCfg("title","项目名称",250));
		cfg.add(new ColumonCfg("money","现金",100));
		/*cfg.add(new ColumonCfg("cloud_money","商币",100));*/
		cfg.add(new ColumonCfg("user_name","会员名",150));
		cfg.add(new ColumonCfg("sn","付款单号",250));
		cfg.add(new ColumonCfg("outer_sn","外部单号",100));
		cfg.add(new ColumonCfg("memo","备注",100));
		cfg.add(new ColumonCfg("payment_name","支付方式",100));
		cfg.add(new ColumonCfg("outer_time","支付时间",160));
		cfg.add(new ColumonCfg("ispay","是否支付",100));			

		ExcelExportor.exportExcelByCfg("充值记录.xls", cfg, list);
		
		return null;
	}
	
	
	/**
	 * 转帐记录列表
	 */
	@RequestMapping(value = "/account/notice/transfer")
	public ModelAndView transferList(@ModelAttribute AccountNoticeQryDto dto) {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/pages/account/transferNoticeList");

		String pageStr = request.getParameter("pageIndex");
		Integer pageIndex = Integer.parseInt(StringUtils.isNullOrEmpty(pageStr) ? "1" : pageStr);

		String sizeStr = request.getParameter("pageSize");
		Integer pageSize = Integer.parseInt(StringUtils.isNullOrEmpty(sizeStr) ? "10" : sizeStr);

		List<Map<String, Object>> pmMapList = paymentService.getPaymentList("");
		
		setDefaultDateTimeRange(dto);		
		Pager pager = new Pager(pageIndex, pageSize);
		List<Map<String, Object>> list = noticeService.getTransferPage(pager,dto);
		mv.addObject("list", list);
		mv.addObject("pager", pager);
		mv.addObject("paymentList", pmMapList);
		mv.addObject("dto", dto==null?new AccountNoticeQryDto():dto);
		return mv;
	}

	/**
	 * 转帐记录列表导出
	 */
	@RequestMapping(value = "/account/notice/transfer/export")
	public ModelAndView transferListExport(@ModelAttribute AccountNoticeQryDto dto) {
		ModelAndView mv = new ModelAndView();	
		List<Map<String, Object>> list = noticeService.getTransferPageExport(dto);
		
		List<ColumonCfg> cfg=new ArrayList<>();
		cfg.add(new ColumonCfg("title","项目名称",250));
		cfg.add(new ColumonCfg("money","现金",100));
		cfg.add(new ColumonCfg("cloud_money","商币",100));
		cfg.add(new ColumonCfg("user_name","会员名",150));
		cfg.add(new ColumonCfg("sn","付款单号",250));
		cfg.add(new ColumonCfg("outer_sn","外部单号",100));
		cfg.add(new ColumonCfg("memo","备注",100));
		cfg.add(new ColumonCfg("payment_name","支付方式",100));
		cfg.add(new ColumonCfg("outer_time","支付时间",160));
		cfg.add(new ColumonCfg("ispay","是否支付",100));			

		ExcelExportor.exportExcelByCfg("转帐记录.xls", cfg, list);
		
		return null;
	}
	
	/**
	 * 提现申请列表
	 */
	@RequestMapping(value = "/account/notice/cash/ask")
	public ModelAndView cashAskList(@ModelAttribute AccountNoticeQryDto dto) {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/pages/account/cashAskList");

		String pageStr = request.getParameter("pageIndex");
		Integer pageIndex = Integer.parseInt(StringUtils.isNullOrEmpty(pageStr) ? "1" : pageStr);

		String sizeStr = request.getParameter("pageSize");
		Integer pageSize = Integer.parseInt(StringUtils.isNullOrEmpty(sizeStr) ? "20" : sizeStr);
		
		setDefaultDateTimeRange(dto);
		Pager pager = new Pager(pageIndex, pageSize);
		List<Map<String, Object>> list = noticeService.getCashAskPage(pager, dto);
		mv.addObject("list", list);
		mv.addObject("pager", pager);
		mv.addObject("dto", dto==null?new AccountNoticeQryDto():dto);
		return mv;
	}
	
	
	
	/**
	 * 提现申请列表--导出
	 * @return 
	 */
	@RequestMapping(value = "/account/notice/cash/ask/export")
	public ModelAndView cashAskListExport(@ModelAttribute AccountNoticeQryDto dto) {
		ModelAndView mv = new ModelAndView();	
		List<Map<String, Object>> list = noticeService.getCashAskPageExport(dto);
		
		List<ColumonCfg> cfg=new ArrayList<>();
		cfg.add(new ColumonCfg("id","编号",50));
		cfg.add(new ColumonCfg("money","金额",100));
		cfg.add(new ColumonCfg("user_name","会员名",150));
		cfg.add(new ColumonCfg("create_time_ch","申请时间",150));
		cfg.add(new ColumonCfg("memo","申请备注",100));
		cfg.add(new ColumonCfg("bank_card","银行卡",280));
		cfg.add(new ColumonCfg("identify_name","持卡人",100));
		cfg.add(new ColumonCfg("bank_name","开户行",130));
		cfg.add(new ColumonCfg("bank_zone","支行",130));
		cfg.add(new ColumonCfg("audit_time_ch","审核时间",150));
		cfg.add(new ColumonCfg("audit_status_ch","审核状态",100));	

		ExcelExportor.exportExcelByCfg("提现记录.xls", cfg, list);
		
		return null;
	}
	
	

	/**
	 * 提现记录列表
	 */
	@RequestMapping(value = "/account/notice/cash")
	public ModelAndView cashList(@ModelAttribute AccountNoticeQryDto dto) {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/pages/account/cashNoticeList");

		String pageStr = request.getParameter("pageIndex");
		Integer pageIndex = Integer.parseInt(StringUtils.isNullOrEmpty(pageStr) ? "1" : pageStr);

		String sizeStr = request.getParameter("pageSize");
		Integer pageSize = Integer.parseInt(StringUtils.isNullOrEmpty(sizeStr) ? "10" : sizeStr);
		
		setDefaultDateTimeRange(dto);
		Pager pager = new Pager(pageIndex, pageSize);
		List<Map<String, Object>> list = noticeService.getCashPage(pager,dto);
		mv.addObject("list", list);
		mv.addObject("pager", pager);
		mv.addObject("dto", dto==null?new UserEditDto():dto);
		return mv;
	}
	
	
	/**
	 * 提现记录列表--导出
	 * @return 
	 */
	@RequestMapping(value = "/account/notice/cash/export")
	public ModelAndView cashListExport(@ModelAttribute AccountNoticeQryDto dto) {
		ModelAndView mv = new ModelAndView();	
		List<Map<String, Object>> list = noticeService.getCashPageExport(dto);
		
		List<ColumonCfg> cfg=new ArrayList<>();
		cfg.add(new ColumonCfg("title","项目名称",250));
		cfg.add(new ColumonCfg("user_name","会员名",100));
		cfg.add(new ColumonCfg("real_name","真实姓名",100));
		cfg.add(new ColumonCfg("sn","付款单号",250));
		cfg.add(new ColumonCfg("outer_sn","外部单号",250));
		cfg.add(new ColumonCfg("bank_card","提现卡号",250));
		cfg.add(new ColumonCfg("bank_name","开户行",250));
		cfg.add(new ColumonCfg("memo","备注",250));
		cfg.add(new ColumonCfg("payment_name","支付方式",100));
		cfg.add(new ColumonCfg("create_time","创建时间",250));
		cfg.add(new ColumonCfg("outer_time","支付时间",250));
		cfg.add(new ColumonCfg("is_paid_ch","是否支付",60));		

		ExcelExportor.exportExcelByCfg("提现记录.xls", cfg, list);
		
		return null;
	}

	/**
	 * 会员升级记录
	 */
	@RequestMapping(value = "/account/notice/upgrade")
	public ModelAndView upgradeList(@ModelAttribute AccountNoticeQryDto dto) {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/pages/account/upgradeNoticeList");

		String pageStr = request.getParameter("pageIndex");
		Integer pageIndex = Integer.parseInt(StringUtils.isNullOrEmpty(pageStr) ? "1" : pageStr);

		String sizeStr = request.getParameter("pageSize");
		Integer pageSize = Integer.parseInt(StringUtils.isNullOrEmpty(sizeStr) ? "10" : sizeStr);
		
		setDefaultDateTimeRange(dto);
		Pager pager = new Pager(pageIndex, pageSize);
		List<Map<String, Object>> list = noticeService.getUpgradePage(pager, dto);
		mv.addObject("list", list);
		mv.addObject("pager", pager);
		mv.addObject("dto", dto==null?new UserEditDto():dto);
		return mv;
	}

	/**
	 * 提现申请审核通过
	 */
	@ResponseBody
	@RequestMapping(value = "/account/audit/cash/pass/{askid}")
	public PageJosnMessage pass(@PathVariable(value = "askid") Integer askid) {
		String ip=IpUtil.getIpAddr(request);
		int adminId = UserContext.getLoginUser().getId();
		String adminName = UserContext.getLoginUser().getLoginName();
		Integer res = accService.auditCash(askid, true, null,adminId,adminName,ip);
		PageJosnMessage msg = new PageJosnMessage();
		res = (res == null ? 1 : res);
		msg.putData("status", res > 0 ? 1 : 0);
		return msg;
	}

	/**
	 * 添加提现申请审核消息
	 */
	@ResponseBody
	@RequestMapping(value = "/account/audit/cash/refuse/msg/{askid}")
	public ModelAndView refuseMsg(@PathVariable(value = "askid") Integer askid) {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/pages/account/auditCashRefuseMsg");
		mv.addObject("askid", askid);
		return mv;
	}

	/**
	 * 提现申请审核未通过
	 */
	@ResponseBody
	@RequestMapping(value = "/account/audit/cash/refuse")
	public ModelAndView refuse(@RequestParam(value = "askid") Integer askid,
			@RequestParam(value = "msg") String auditMsg) {
		String ip=IpUtil.getIpAddr(request);
		int adminId = UserContext.getLoginUser().getId();
		String adminName = UserContext.getLoginUser().getLoginName();
		Integer res = accService.auditCash(askid, false, auditMsg,adminId,adminName,ip);
		ModelAndView mv = refuseMsg(askid);
		mv.addObject("askid", askid);
		mv.addObject("msg", auditMsg);

		String msg = "";
		if (res == 1)
			msg = PageTools.alertCloseFraRefresh("提现审核", "审核成功！", 1000);
		else
			msg = PageTools.alert("提现审核", "审核失败，请稍后重试！", 1000);
		mv.addObject("actionMsg", msg);
		return mv;
	}

	/**
	 * 撤消提现申请
	 */
	@ResponseBody
	@RequestMapping(value = "/account/audit/cash/cancel/{askid}")
	public PageJosnMessage cancel(@PathVariable(value = "askid") Integer askid) {
		Integer res = accService.auditCashCancel(askid);
		PageJosnMessage msg = new PageJosnMessage();
		res = (res == null ? 1 : res);
		msg.putData("status", res > 0 ? 1 : 0);
		return msg;
	}

	/**
	 * 添加提现申请审核消息
	 */
	@ResponseBody
	@RequestMapping(value = "/account/audit/cash/pay/msg/{askid}")
	public ModelAndView payMsg(@PathVariable(value = "askid") Integer askid) {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/pages/account/auditCashPayMsg");
		mv.addObject("askid", askid);
		return mv;
	}

	/**
	 * 审核--确认支付
	 */
	@ResponseBody
	@RequestMapping(value = "/account/audit/cash/pay")
	public ModelAndView pay(@RequestParam(value = "askid") Integer askid, @RequestParam(value = "msg") String payMsg) {
		String ip=IpUtil.getIpAddr(request);
		Integer res = accService.auditPay(askid, payMsg,UserContext.getLoginUser().getId(),UserContext.getLoginUser().getLoginName(),ip);
		ModelAndView mv = payMsg(askid);
		mv.addObject("askid", askid);
		mv.addObject("msg", payMsg);

		String msg = "";
		if (res == 1)
			msg = PageTools.alertCloseFraRefresh("提现审核", "批量确认打款成功！", 1000);
		else
			msg = PageTools.alert("提现审核", "批量确认打款成功失败，请稍后重试！", 1000);
		mv.addObject("actionMsg", msg);
		return mv;
	}

	
	/**
	 * 添加提现申请审核消息_批量
	 */
	@ResponseBody
	@RequestMapping(value = "/account/audit/cash/pay/batch/msg/{askid}")
	public ModelAndView payMsgBatch(@PathVariable(value = "askid") String askidList) {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/pages/account/auditCashBatchPayMsg");
		mv.addObject("askidList", askidList);
		return mv;
	}

	/**
	 * 审核--确认支付_批量
	 */
	@ResponseBody
	@RequestMapping(value = "/account/audit/cash/pay/batch")
	public ModelAndView payBatch(@RequestParam(value = "askidList") String askidList, @RequestParam(value = "msg") String payMsg) {
		String ip=IpUtil.getIpAddr(request);
		Integer res = accService.auditPayBatch(askidList, payMsg,UserContext.getLoginUser().getId(),UserContext.getLoginUser().getLoginName(),ip);
		ModelAndView mv = payMsgBatch(askidList);
		mv.addObject("askidList", askidList);
		mv.addObject("msg", payMsg);

		String msg = "";
		if (res == 1)
			msg = PageTools.alertCloseFraRefresh("提现批量审核", "批量打款完成！", 1000);
		else if (res == 2)
			msg = PageTools.alertCloseFraRefresh("提现提现审核", "批量打款完成,部分未通过,请检测选中记录是否通过审核！", 2000);
		else
			msg = PageTools.alert("提现提现审核", "打款失败，请检测选中记录是否通过审核！", 2000);
		mv.addObject("actionMsg", msg);
		return mv;
	}
	
	/**
	 * 合作伙伴返币记录
	 */
	@RequestMapping(value = "/account/notice/partner")
	public ModelAndView patnerReturnCloudMoney(@ModelAttribute AccountNoticeQryDto dto) {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/pages/account/partnerNoticeList");

		String pageStr = request.getParameter("pageIndex");
		Integer pageIndex = Integer.parseInt(StringUtils.isNullOrEmpty(pageStr) ? "1" : pageStr);

		String sizeStr = request.getParameter("pageSize");
		Integer pageSize = Integer.parseInt(StringUtils.isNullOrEmpty(sizeStr) ? "10" : sizeStr);
		
		setDefaultDateTimeRange(dto);
		Pager pager = new Pager(pageIndex, pageSize);
		List<Map<String, Object>> list = noticeService.patnerReturnCloudMoney(pager, dto);
		mv.addObject("list", list);
		mv.addObject("pager", pager);
		mv.addObject("dto", dto==null?new UserEditDto():dto);
		return mv;
	}
	
	
	/**
	 * 合作伙伴返币记录--导出
	 */
	@RequestMapping(value = "/account/notice/partner/export")
	public ModelAndView patnerReturnCloudMoneyExport(@ModelAttribute AccountNoticeQryDto dto) {
		ModelAndView mv = new ModelAndView();	
		List<Map<String, Object>> list = noticeService.patnerReturnCloudMoneyExport(dto);
		
		List<ColumonCfg> cfg=new ArrayList<>();
		cfg.add(new ColumonCfg("title","项目名称",250));
		cfg.add(new ColumonCfg("money","现金",100));
		cfg.add(new ColumonCfg("cloud_money","商币",100));
		cfg.add(new ColumonCfg("user_name","会员名",150));
		cfg.add(new ColumonCfg("sn","付款单号",250));
		cfg.add(new ColumonCfg("outer_sn","外部单号",100));
		cfg.add(new ColumonCfg("memo","备注",100));
		cfg.add(new ColumonCfg("payment_name","支付方式",100));
		cfg.add(new ColumonCfg("create_time","支付时间",160));
		cfg.add(new ColumonCfg("ispay","是否支付",100));			

		ExcelExportor.exportExcelByCfg("合作伙伴返币记录.xls", cfg, list);
		
		return null;
	}
	
	
	/**
	 * 每日系统返币记录
	 */
	@RequestMapping(value = "/account/notice/sysReturn")
	public ModelAndView sysReturnMoney(@ModelAttribute AccountNoticeQryDto dto) {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/pages/account/sysReturn");

		String pageStr = request.getParameter("pageIndex");
		Integer pageIndex = Integer.parseInt(StringUtils.isNullOrEmpty(pageStr) ? "1" : pageStr);

		String sizeStr = request.getParameter("pageSize");
		Integer pageSize = Integer.parseInt(StringUtils.isNullOrEmpty(sizeStr) ? "10" : sizeStr);
		
		setDefaultDateTimeRange(dto);
		Pager pager = new Pager(pageIndex, pageSize);
		List<Map<String, Object>> list = noticeService.sysReturnMoney(pager, dto);
		mv.addObject("list", list);
		mv.addObject("pager", pager);
		mv.addObject("dto", dto==null?new UserEditDto():dto);
		return mv;
	}	
	
	
	
	
	/**
	 * 赠送商币记录
	 * @param dto
	 * @return
	 */
	@RequestMapping(value = "/account/notice/cloudmoney/send")
	public ModelAndView sendCloudMoney(@ModelAttribute AccountNoticeQryDto dto) {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/pages/account/sendCloudMoney");

		String pageStr = request.getParameter("pageIndex");
		Integer pageIndex = Integer.parseInt(StringUtils.isNullOrEmpty(pageStr) ? "1" : pageStr);

		String sizeStr = request.getParameter("pageSize");
		Integer pageSize = Integer.parseInt(StringUtils.isNullOrEmpty(sizeStr) ? "10" : sizeStr);
		
		setDefaultDateTimeRange(dto);
		Pager pager = new Pager(pageIndex, pageSize);
		List<Map<String, Object>> list = noticeService.getSendCloudMoneyList(pager, dto);
		mv.addObject("list", list);
		mv.addObject("pager", pager);
		mv.addObject("dto", dto==null?new UserEditDto():dto);
		return mv;
	}	
	
	/**
	 * 个人账单记录
	 * @param dto
	 * @return
	 */
	@RequestMapping(value = "/account/notice/noticeRefundDetail")
	public ModelAndView noticeRefundDetail(@ModelAttribute NoticeRefundQryDto dto) {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/pages/account/noticeRefundDetail");

		String pageStr = request.getParameter("pageIndex");
		Integer pageIndex = Integer.parseInt(StringUtils.isNullOrEmpty(pageStr) ? "1" : pageStr);

		String sizeStr = request.getParameter("pageSize");
		Integer pageSize = Integer.parseInt(StringUtils.isNullOrEmpty(sizeStr) ? "10" : sizeStr);

		Pager pager = new Pager(pageIndex, pageSize);
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        if(ApiUtils.objIsEmpty(dto.getCreateTime())&&ApiUtils.objIsEmpty(dto.getCreateTime1())){
        	  Calendar cal=Calendar.getInstance();
    		  cal.setTime(new Date());	
    		  cal.add(Calendar.DAY_OF_MONTH,0);
    		  dto.setCreateTime(sdf.format(cal.getTime()));
    		  dto.setCreateTime1(sdf.format(cal.getTime()));
        }
		List<Map<String, Object>> list = noticeService.getNoticeRefundDetail(pager, dto);
		mv.addObject("list", list);
		mv.addObject("pager", pager);
		mv.addObject("dto", dto);
		return mv;
	}	
	
	
	/**
	 * 个人账单记录导出
	 * @param dto
	 * @return
	 */
	@RequestMapping(value = "/account/notice/noticeRefundDetail/export")
	public ModelAndView noticeRefundDetailExport(@ModelAttribute NoticeRefundQryDto dto) {
		ModelAndView mv = new ModelAndView();
		List<Map<String, Object>> list = noticeService.getNoticeRefundDetailExport(dto);
		List<ColumonCfg> cfg=new ArrayList<>();
		cfg.add(new ColumonCfg("title","项目名称",250));
		cfg.add(new ColumonCfg("money","现金",100));
		cfg.add(new ColumonCfg("cloud_money","商币",100));
		cfg.add(new ColumonCfg("user_name","会员名",150));
		cfg.add(new ColumonCfg("sn","付款单号",250));
		cfg.add(new ColumonCfg("outer_sn","外部单号",100));
		cfg.add(new ColumonCfg("memo","备注",100));
		cfg.add(new ColumonCfg("payment_name","支付方式",100));
		cfg.add(new ColumonCfg("create_time","支付时间",160));
		cfg.add(new ColumonCfg("ispay","是否支付",100));			
		cfg.add(new ColumonCfg("trade_name","账单类型",250));
		ExcelExportor.exportExcelByCfg("个人账单记录.xls", cfg, list);
		mv.addObject(null);
		return mv;
		
		
	}	
	
	
	
	
	
	
}
